﻿@model Yqblog.Models.CategoryModel
@using res = Resource.Admin.Admin;
@{
    ViewBag.NavSelectedItem = "categorysort";
}
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> 
<h1 class="page-title">
    @res.ModifyCategory		
</h1>
<div class="row">			
    <div class="span9">
        <div class="widget">			
            <div class="widget-header">
                <h3>
                    @res.ModifyCategory
                </h3>
            </div>					
            <div class="widget-content">
                <div id="AjaxResult" class="tabbable">
                    @using (Ajax.BeginForm("AdminCategoryEdit", "Admin", FormMethod.Post, new AjaxOptions { LoadingElementId = "Loading", InsertionMode = InsertionMode.InsertBefore, OnSuccess = "ProcessSuccess" }, new { id = "categoryform", name = "categoryform", @class = "form-horizontal" }))
                    {					
                                <fieldset>  
                                    <input type="hidden" value="@Model.CateId" name="CateId" id="CateId"/>
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.CateName, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextBoxFor(m => m.CateName, new { @class = "input-medium" })
                                            @Html.ValidationMessageFor(m => m.CateName)
                                        </div>
                                    </div>
                    
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.ParentId, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.DropDownList("ParentId")
                                        </div>
                                    </div>
                    
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.Type, new { @class = "control-label" })
                                        <div class="controls">
                                            <select disabled=disabled><option value="">@ViewBag.TypeName</option>
                                            </select>
                                            <input type="hidden" value="@ViewBag.TypeId" name="Type" id="Type"/>
                                        </div>
                                    </div>

                                    <div class="control-group replypermit displayInline">
                                        @Html.LabelFor(m => m.ReplyPermit, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="1" name="ReplyPermit" id="ReplyPermit_y" @if (Model.ReplyPermit == 1)
                                                                                                                    {@Html.Raw("checked=\"checked\"")
                                                                                                                    }/>
                                                @res.Yes</label>
                                            <label class="radio">
                                                <input type="radio" value="0" name="ReplyPermit" id="ReplyPermit_n" @if (Model.ReplyPermit != 1)
                                                                                                                    {@Html.Raw("checked=\"checked\"")
                                                                                                                    }/>
                                                @res.No</label>
                                        </div>
                                    </div>

                                    <div class="control-group displayInline">
                                        @Html.LabelFor(m => m.IsNav, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="true" name="IsNav" id="IsNav_y" @if (Model.IsNav)
                                                                                                           {@Html.Raw("checked=\"checked\"")
                                                                                                           }/>
                                                @res.Yes</label>
                                            <label class="radio">
                                                <input type="radio" value="false" name="IsNav" id="IsNav_n" @if (!Model.IsNav)
                                                                                                            {@Html.Raw("checked=\"checked\"")
                                                                                                            }/>
                                                @res.No</label>
                                        </div>
                                    </div>
                    
                                    <div class="control-group isInHomePage displayInline">
                                        @Html.LabelFor(m => m.IsIndex, new { @class = "control-label" })
                                        <div class="controls">
                                            <div id="help_categoryIsIndex" class="pull-right btn_help">?</div>
                                            <label class="radio">
                                                <input type="radio" value="true" name="IsIndex" autocomplete="off" id="IsIndex_y"  @if (Model.IsIndex)
                                                                                                                {@Html.Raw("checked=\"checked\"")
                                                                                                                }/>
                                                @res.Yes</label>
                                            <label class="radio">
                                                <input type="radio" value="false" name="IsIndex" autocomplete="off" id="IsIndex_n" @if (!Model.IsIndex)
                                                                                                                {@Html.Raw("checked=\"checked\"")
                                                                                                                }/>
                                                @res.No</label>
                                        </div>
                                    </div>
                                    <div class="categoryIsIndexDetail hide">
                                    <div class="control-group listNum isInHomePage">
                              <label class="control-label"><span></span></label>
                            <div class="controls">
                                @Html.LabelFor(m => m.ListNum)
                                @Html.TextBoxFor(m => m.ListNum, new { @class = "input-mini" })
                                @Html.ValidationMessageFor(m => m.ListNum)
                            </div>
                        </div>
                            <div class="control-group isInHomePage">
                                <label class="control-label"><span></span></label>
                                <div class="controls">
                                    @Html.LabelFor(m => m.HomePageKey)
                                    @Html.TextBoxFor(m => m.HomePageKey, new { @class = "input-medium" })
                                    <br>
                                    @Html.ValidationMessageFor(m => m.HomePageKey)
                                </div>
                            </div>
                                    </div>
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.ReName, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextBoxFor(m => m.ReName, new { @class = "input-medium" })
                                            @Html.ValidationMessageFor(m => m.ReName)
                                        </div>
                                    </div>
                    
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.CustomView, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextBoxFor(m => m.CustomView, new { @class = "input-medium" })
                                            @Html.ValidationMessageFor(m => m.CustomView)
                                        </div>
                                    </div>
                    
                                    <div class="control-group">
                                        @Html.LabelFor(m => m.Description, new { @class = "control-label" })
                                        <div class="controls">
                                            @Html.TextAreaFor(model => model.Description)
                                            @Html.ValidationMessageFor(m => m.Description)
                                        </div>
                                    </div>

                                    <div class="control-group displayInline">
                                        @Html.LabelFor(m => m.Status, new { @class = "control-label" })
                                        <div class="controls">
                                            <label class="radio">
                                                <input type="radio" value="1" name="Status" id="Status_y" @if (Model.Status == 1)
                                                                                                          {@Html.Raw("checked=\"checked\"")
                                                                                                          }/>
                                                @res.Normal</label>
                                            <label class="radio">
                                                <input type="radio" value="2" name="Status" id="Status_n" @if (Model.Status == 2)
                                                                                                          {@Html.Raw("checked=\"checked\"")
                                                                                                          }/>
                                                @res.Close
                                            </label>
                                        </div>
                                    </div>

                                </fieldset>
                            <div class="form-actions">
                                <button id="BtnSubmit"  class="btn btn-primary" type="submit">@res.Submit</button> 
                                <a class="btn btn_cancel">@res.Cancel</a>
                                <span id="Loading" class="hide"> @res.Loading</span>
                            </div>
                    }
                </div> 		
            </div> 		
        </div>
    </div>		
</div>
<input type="hidden" id="deletetypeid" name="deletetypeid" value=""/>
<input type="hidden" id="deletecateid" name="deletecateid" value=""/>
<input type="hidden" id="deletefield" name="deletefield" value=""/>
@section Js{
    <script type="text/javascript">
        function ProcessSuccess() {
            Go('@Url.Action("AdminCategorySort", "Admin")');
        }

        var defaulTab = @(ViewBag.Tab);
        $(function() {
            if (defaulTab != 1) {
                $($('.widget-content .nav-tabs a')[defaulTab-1]).trigger('click');
            }
            
            if ($('input[name=IsIndex]').val()=="true") {
                $('.categoryIsIndexDetail').show();
            }
            $('input[name=IsIndex]').on("click",function() {
                if ($(this).val()=='true') {
                    $('.categoryIsIndexDetail').show();
                } else {
                    $('.categoryIsIndexDetail').hide();
                }
            });
        });
    </script> 
}